package epam.bookShelf.bookStuff;

public class BookBuilder {   
    private long    id;
    private String  title;
    private long    isbn;
    private long    dat;
    private long    readedDate;
    private String  description;
    private long    borrowRecordId;
    private String  authorName;
    private long    locationId;
    private String  readerLogin;
    
    public BookBuilder() {
        readedDate      = -1;
        dat             = -1;
        isbn            = -1;
        id              = -1;
        borrowRecordId  = -1;
        locationId      = -1;
    }
    
    public Book getBook() {
        Book rez = new Book(title);
        
        rez.setId(id);
        
        if (authorName != null) {            
            rez.setAuthorName(authorName);
        }
        
        rez.setLocationId(locationId);
        
        rez.setReadedDate(readedDate);

        if (dat > 0) {
            rez.setDat(dat);
        } else {
            rez.setDat(0);
        }
        
        rez.setIsbn(isbn);
        
        rez.setDescription(description);
        
        rez.setBorrowRecordId(borrowRecordId);
        
        if (readerLogin != null) {
            rez.setReaderLogin(readerLogin);
        } else {
            rez.setReaderLogin("default_login");
        }            
        
        return rez;
    }
    
    public String getTitle() {
        return title;
    }
    public void setTitle(String title) {
        if (title.length() > 0) {
            this.title = title;
        } else {
            this.title = null;
        }
    }

    public long getReadedDate() {
        return readedDate;
    }
    public void setReadedDate(long readedDate) {
        this.readedDate = readedDate;
    }
    public long getDat() {
        return dat;
    }
    public void setDat(long dat) {
        this.dat = dat;
    }
    public long getIsbn() {
        return isbn;
    }
    public void setIsbn(long isbn) {
        this.isbn = isbn;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }

    public void setId(long id) {
        this.id = id;
    }

    public long getId() {
        return id;
    }

    public void setBorrowRecordId(long borrowRecordId) {
        this.borrowRecordId = borrowRecordId;
    }

    public long getBorrowRecordId() {
        return borrowRecordId;
    }

    public void setUserLogin(String userLogin) {
        this.readerLogin = userLogin;
    }

    public String getUserLogin() {
        return readerLogin;
    }

    public void setLocationId(long locationId) {
        this.locationId = locationId;
    }

    public long getLocationId() {
        return locationId;
    }     
    
    public String getAuthorName() {
        return authorName;
    }

    public void setAuthorName(String authorName) {
        this.authorName = authorName;
    }
}
